/**
rid: 118885
user: 04172604ZDY
time: 2017-11-26 17:43:11
result: Runtime Error 
*/
//使用循环处理数据,改double类型,不使用scanf与printf
#include <iostream>
#include <iomanip>
//#include <vector>
using namespace std;

double T[125][125];
int aims[10005];
double data[125][10005];

void deal(int R, int hasAimCount) {
    for(int i = 0; i < hasAimCount; i++)
        for(int j = 0; j < R; j++) {
            int aim = aims[hasAimCount-i-1];
            data[j][i] = T[j][aim];
            if(i > 0) {
                double orig = data[j][i - 1];
                double replace = data[aim][i - 1];
                data[j][i] *= (orig > replace ? orig : replace);
            }
        }
}

int main() {
    int n;
    while(cin >> n) {
        int R = n*(n-1)*(n-2)/6;//max 120
        //init T
        for(int i = 0; i < R; i++) {
            for(int j = 0; j < R; j++) {
                cin >> T[i][j];
            }
        }
        //init aims
        int aimCount;
        cin >> aimCount;
        for(int i = 0; i < aimCount; i++) {
            cin >> aims[i];
        }
        //deal with data
        deal(R, aimCount);
        double result;
        result = 0;
        for(int i = 0; i < R; i++) {
            double cache = data[i][aimCount-1];
            if(cache > result)
                result = cache;
        }
        //output
        cout << std::fixed << setprecision(6) << result << endl;
    }
    return 0;
}